<?php namespace Admin\Controller;
use Common\Controller\AdminBaseController;
/**
 * 文章管理
 */
class ArticleController extends AdminBaseController
{
	//定义数据表
	private $db;

	//构造函数，实例化ArticleModel
	public function __construct(){
		parent::__construct();
		$this->db=D('Article');
	}

	//文章列表
	public function index(){
		$data=$this->db->getPageData('all','all','all',0,15);
        $this->assign('data',$data['data']);
        $this->assign('page',$data['page']);
		$this->display();
	}

	//添加文章
	public function add(){
		if (IS_POST) {
			if ($this->db->addData()) {
				$this->success('添加成功','index');
			}else{
				$this->eror('添加失败');
			}
		}else{
			$allCategory=D('Category')->getAllData();
			if(!$allCategory) $this->error('请先添加分类','Category/index');
			$allTag=D('Tag')->getAllData();
			$this->assign('allCategory',$allCategory);
            $this->assign('allTag',$allTag);
			$this->display();
		}
	}


}
